package com.loveprogrammer.model;

/**
 * @version 1.0.0
 * @description: 掉落的金币的封装
 * @author: eric
 * @date: 2022-08-08 18:02
 **/
public class Coin {

    /**
     * 金币
     **/
    private int goldCoin;

    /**
     * 钻石
     **/
    private int diamonds;

    public Coin addGoldCoin(int num){
        this.goldCoin = this.goldCoin + num;
        return this;
    }

    public Coin addDiamonds(int num){
        this.diamonds = this.diamonds + num;
        return this;
    }

    public int getGoldCoin() {
        return goldCoin;
    }

    public void setGoldCoin(int goldCoin) {
        this.goldCoin = goldCoin;
    }

    public int getDiamonds() {
        return diamonds;
    }

    public void setDiamonds(int diamonds) {
        this.diamonds = diamonds;
    }

    public Coin add(Coin fallingCoin) {
        this.goldCoin += fallingCoin.getGoldCoin();
        this.diamonds += fallingCoin.getDiamonds();
        return this;
    }

    @Override
    public String toString() {
        return "Coin{" +
                " 金币=" + goldCoin +
                ", 钻石=" + diamonds +
                '}';
    }

    public String showPrice(){
        if(diamonds > 0){
            return  diamonds + "钻石";
        }
        return  goldCoin + "金币";
    }
}
